package com.example.homeworkmutualevaluation.utils;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;


public class UniqueId {
    private static final Snowflake snowflake = IdUtil.getSnowflake();
    public static String next(int n) {
        long snowflakeId = snowflake.nextId();
        StringBuilder str = new StringBuilder(Base64.toBase64(snowflakeId));
        if (str.length() >= n)
            return str.substring(0, n);
        while (str.length() < n)
            str.append(Base64.randNext());
        return str.toString();
    }
    public static String next() {
        return next(20);
    }
}
